package PartIIWeek1;

/**
 * @author Kent HAN
 * @date 2021/7/4
 */
public class Outcast2 {

    private WordNet3 worknet;

    public Outcast2(WordNet3 wordnet) {
        this.worknet = wordnet;
    }

    public String outcast(String[] nouns) {

        String outcast = null;
        int max = 0;

        for(String noun : nouns) {
            int distance = 0;
            for(String noun2 : nouns) {
                if(noun != noun2) {
                    distance += this.worknet.distance(noun, noun2);
                }
            }

            if(distance > max) {
                max = distance;
                outcast = noun;
            }
        }

        return outcast;
    }

    public static void main(String[] args) {

        Outcast3 out = new Outcast3(new WordNet3("synsets.txt", "hypernyms.txt"));
        String[] nouns = new String[]{"horse", "zebra", "cat", "bear", "table"};

        System.out.println(out.outcast(nouns));
    }
}
